#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10, M = N * 2;
int h[N], e[M], ne[M], idx;
LL f[N];
int sz[N];
int n, m;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void dfs1(int u, int fa,int step)
{
	sz[u] = 1;
	f[1] += step;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j == fa)continue;
		dfs1(j, u, step + 1);
		sz[u] += sz[j];
	}
}

void dfs2(int u, int fa)
{
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j == fa)continue;
		f[j] = f[u] - sz[j] + (n - sz[j]);
		dfs2(j, u);
	}
}

int main()
{
	cin >> n;
	memset(h, -1, sizeof(h));
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
	}
	dfs1(1, 0, 0);
	//cout << "f[1]==" << f[1] << endl;
	dfs2(1, 0);
	int ans = 1;
	LL res = f[1];
	for (int i = 2; i <= n; i++) {
		if (f[i] > res) {
			res = f[i];
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}